

//**************************C:\wamp\www\nd/Native2DDisplay/monster/org/algo/sort/QSort.js**************************

/**
 * ...
 * @author HTML5
 */

function QSort() {}


QSort.zorder = function(p_a, p_b)
{
	return ( p_a.z < p_b.z ) ? -1 : 1;
};


QSort.sort = function( p_children )
{
	return p_children.sort( QSort.zorder );
};





//**************************C:\wamp\www\nd/Native2DDisplay/monster/org/algo/sort/Radix.js**************************

/**
 * ...
 * @author HTML5
 */

function Radix() {}


Radix.sortInt = function( p_array )
{
	var tab = p_array;
	var buckets = null;
	var max = p_array.length;
	var i = 0;
	var j = 0;
	var k = 0;
	var l = 0;
	var value = 0;
	var el = null;
	var curbuck = null;
	var shift = 0;
	
	if( p_array.length == 0 )
	{
		return p_array;
	}
	
	l = 0;
	j = 0;
	i = 0;
	
	while( i < 4  )
	{
		buckets = [];
		max = tab.length;
		j = 0;
		
		while( j < 512 )
		{
			buckets[j] = new Array();
			j++;
		}
		
		j = 0;
		
		
		while( j < max )
		{
			el = tab[j];
			value = ( el & (255 << (shift)) ) >> (shift);
			value = ( value > 0 ) ? 256 + value : 255 + value;
			buckets[value].push(el);
			j++;
		}
		

		
		j = 0;
		k = 0;
		l = 0;
		
		while( j < 512 )
		{
			curbuck = buckets[j];
			max = curbuck.length;
			
			k = 0;
			while( k < max )
			{
				tab[l] = curbuck[k];
				l++;
				k++;
			}
			j++;
		}
		
		shift+=8;
		i++;
	}
	
	
	
	return tab;
};

Radix.sortByProperty = function( p_array, p_prop )
{
	var tab = p_array;
	var buckets = null;
	var max = p_array.length;
	var i = 0;
	var j = 0;
	var k = 0;
	var l = 0;
	var value = 0;
	var el = null;
	var curbuck = null;
	
	l = 0;
	j = 0;
	i = 0;
	
	
	if( p_array.length == 0 )
	{
		return p_array;
	}
	
	while( i < 4  )
	{
		
		
		buckets = [];
		max = tab.length;
		j = 0;
		
		while( j < 512 )
		{
			buckets[j] = new Array();
			j++;
		}
		
		j = 0;
		
		
		while( j < max )
		{
			el = tab[j];
			value = ( el[p_prop] & (255 << (i*8)) ) >> (i*8);
			value = ( value > 0 ) ? 256 + value : 255 + value;
			buckets[value].push(el);
			j++;
		}

		
		j = 0;
		k = 0;
		l = 0;
		
		while( j < 512 )
		{
			curbuck = buckets[j];
			max = curbuck.length;
			
			k = 0;
			while( k < max )
			{
				tab[l] = curbuck[k];
				l++;
				k++;
			}
			j++;
		}
		
		i++;
	}
	
	return tab;
};



//**************************C:\wamp\www\nd/Native2DDisplay/monster/org/display/animation/Animation.js**************************

/**
 * ...
 * @author HTML5
 */

function Animation() 
{
	this.data = new Array();
}

Animation.prototype.data = null;
Animation.prototype.frame = 0;
Animation.prototype.sprite = null;
Animation.prototype.animationTime = 16;
Animation.prototype._lastTime = 0;

Animation.prototype.setFrame = function( p_frameId, p_uv, p_textureId ) 
{
	this.data[p_frameId] = {"uv":p_uv,"tex":p_textureId};
};

Animation.prototype.animate = function( p_time )
{
	if( p_time - this._lastTime < this.animationTime )
	{
		return;
	}
	
	this._lastTime = p_time;
	var frameObj = null;
	this.frame++;
	
	if( this.frame == this.data.length )
	{
		this.frame = 0;
	}
	
	frameObj = this.data[this.frame];
	
	this.sprite.uv 			= frameObj.uv;
	this.sprite.textureId 	= frameObj.tex;
};

Animation.prototype.destroy = function()
{
	this.data = null;
};



//**************************C:\wamp\www\nd/Native2DDisplay/monster/org/display/animation/AnimationManager.js**************************

/**
 * ...
 * @author HTML5
 */

function AnimationManager() {}


AnimationManager._instance = null;
AnimationManager.getInstance = function()
{
	if( AnimationManager._instance == null )
	{
		AnimationManager._instance = new AnimationManager();
		AnimationManager._instance.init();
	}
	
	
	return AnimationManager._instance;
};



AnimationManager.prototype._animations = null;


AnimationManager.prototype.init = function()
{
	this._animations = new Object();
};

AnimationManager.prototype.registerAnimation = function( p_animation, p_animationId )
{
	this._animations[p_animationId] = p_animation;
};

AnimationManager.prototype.getAnimationById = function( p_animationId )
{
	return this._animations[p_animationId];
};

AnimationManager.prototype.removeAnimationById = function( p_animationId )
{
	if( this._animations[p_animationId] )
	{
		delete this._animations[p_animationId];
	}
};

AnimationManager.prototype.animateAll = function()
{
	var prop = null;
	var anim = null;
	var time = new Date().getTime();
	
	for( prop in this._animations )
	{
		anim = this._animations[prop];
		anim.animate(time);
	}
};


AnimationManager.prototype.destroy = function()
{
	AnimationManager._instance = null;
	this._animations = null;
};













//**************************C:\wamp\www\nd/Native2DDisplay/monster/org/display/boost/BSPTree.js**************************

/**

 * ...

 * @author Thot

 */



function BSPTree(){}


BSPTree.frame					= 0;
BSPTree.X_AXIS					= "x_axis";
BSPTree.Y_AXIS					= "y_axis";


BSPTree.prototype.n 			= 0;		// tree depth
BSPTree.prototype.parentNode 	= null;
BSPTree.prototype.front 		= null;
BSPTree.prototype.back 			= null;
BSPTree.prototype.children		= new Array();
BSPTree.prototype.axis			= BSPTree.X_AXIS;


BSPTree.prototype.depthLimit	= 10;
BSPTree.prototype.childrenLimit	= 50;
BSPTree.prototype.isLeaf		= true;
BSPTree.prototype.width			= 0;
BSPTree.prototype.x				= 0;
BSPTree.prototype.y				= 0;
BSPTree.prototype.height		= 0;
BSPTree.prototype.limit			= 0;
BSPTree.prototype.axisP1		= "";
BSPTree.prototype.axisP2		= "";



BSPTree.prototype.addChild 	= function( p_child )
{
	
	var i = 0;
	var l_max = 0;
	
	
	if( this.isLeaf )
	{
		this.children.push( p_child );
	}
	else
	{
		this.addElement( p_child, this.limit, this.axisP1, this.axisP2);
	}
	
	
	if( this.children.length > this.childrenLimit && this.n < this.depthLimit )
	{
		
		this.createBackAndFront();
		
		l_max = this.children.length;
		
		for( i = 0; i < l_max; i++ )
		{
			this.addElement( this.children[i], this.limit, this.axisP1, this.axisP2);
		}
		
		this.children = new Array();
		
	}
	
	
};


BSPTree.prototype.addElement = function( p_child, p_limit, p_p1, p_p2 )
{
	if( ( p_child[p_p1] ) < p_limit )
	{
		if( ( p_child[p_p1] + p_child[p_p2] ) >= p_limit )
		{
			this.front.addChild( p_child );
		}
		
		this.back.addChild( p_child );
	}
	else
	{
		this.front.addChild( p_child );
	}
};


BSPTree.prototype.removeChild = function( p_child )
{
	var l_index = this.children.indexOf( p_child );
	
	if( this.isLeaf || l_index != -1 )
	{
		if( l_index != -1 )
		{
			this.children.splice( l_index , 1 );
		}
	}
	else
	{
		this.front.removeChild( p_child );
		this.back.removeChild( p_child );
	}
};


BSPTree.prototype.createBackAndFront = function()
{
	
	
	this.back 	= new BSPTree();
	this.front 	= new BSPTree();
	
	
	if( this.axis == BSPTree.X_AXIS )
	{
		
		
		this.back.init( 	this.x, 
							this.y, 
							this.width * 0.5, 	
							this.height,
							this.n + 1, 
							BSPTree.Y_AXIS, 
							this,
							this.depthLimit,
							this.childrenLimit );
		
		this.front.init( 	this.x + ( this.width * 0.5 ),
							this.y, 
							this.width * 0.5, 	
							this.height, 
							this.n + 1, 
							BSPTree.Y_AXIS, 
							this,
							this.depthLimit,
							this.childrenLimit );
	}
	else
	{
		
		
		this.back.init( 	this.x, 
							this.y, 
							this.width, 	
							this.height * 0.5, 
							this.n + 1, 
							BSPTree.X_AXIS, 
							this,
							this.depthLimit,
							this.childrenLimit );
		
		
		this.front.init( 	this.x, 
							this.y + ( this.height * 0.5 ),
							this.width,	
							this.height * 0.5, 
							this.n + 1, 
							BSPTree.X_AXIS, 
							this,
							this.depthLimit,
							this.childrenLimit );
	}

	this.isLeaf = false;

};


BSPTree.prototype.init 	= function( p_x, p_y, p_width, p_height, p_n, p_axis, p_parentNode, p_nLimit, p_cLimit )
{
	
	this.x 			= p_x;
	this.y 			= p_y;
	this.width 		= p_width;
	this.height 	= p_height;
	this.axis 		= p_axis;
	this.parentNode = p_parentNode;
	this.n 			= p_n;
	this.children 	= new Array();
	this.isLeaf 	= true;
	this.limit 		= ( this.axis == BSPTree.X_AXIS ) ? this.x + ( this.width * 0.5 ) : this.y + ( this.height * 0.5 );
	this.axisP1 	= ( this.axis == BSPTree.X_AXIS ) ? "x" : "y";
	this.axisP2 	= ( this.axis == BSPTree.X_AXIS ) ? "width" : "height";
	this.childrenLimit  = p_cLimit;
	this.depthLimit 	= p_nLimit;

};


// traversal methods



BSPTree.prototype.getVisibleChildrenIn = function ( p_x, p_y, p_width, p_height )
{
	var children = this.getVisibleChildrenRecursive( p_x, p_y, p_width, p_height );
	return this.filter( children, p_x, p_y, p_width, p_height );
}

BSPTree.prototype.getVisibleChildrenIterative 	= function( p_x, p_y, p_width, p_height )
{
	
	var l_current;
	var l_right = p_width + p_x;
	var l_down = p_height + p_y;
	var l_children = new Array();
	var l_nodeTable = new Array( this );
	var l_loop = true;
	
	
	while( l_loop )
	{
		l_current = l_nodeTable.shift();
		l_loop = ( l_nodeTable.length > 0 );
		
		
		if( l_current.y > l_down )
			continue;
		
		if( l_current.x > l_right )
			continue;
		
		
		if( l_current.y + l_current.height < p_y )
			continue;
			
		if( l_current.x + l_current.width < p_x )
			continue;	
			
		
		
		if( l_current.isLeaf )
		{
			l_children = l_children.concat( l_current.children );
		}
		else
		{
			l_nodeTable.push( l_current.front );
			l_nodeTable.push( l_current.back );
			l_loop = true;
		}
		
	}
	
	return l_children;

	
};


BSPTree.prototype.getVisibleChildrenRecursive 	= function( p_x, p_y, p_width, p_height, p_exact )
{
	var l_children = this.getChildrenIn( p_x, p_y, p_width, p_height );
	return l_children;
};


BSPTree.prototype.getChildrenIn 				= function( p_x, p_y, p_width, p_height )
{
	
	var l_right = p_width + p_x;
	var l_down = p_height + p_y;
	var l_return = new Array();
	
	
	if( this.x + this.width < p_x )
	{
		return l_return;
	}
	
	if( this.x > l_right )
	{
		return l_return;
	}
	
	if( this.y + this.height < p_y )
	{
		return l_return;
	}
	
	if( this.y > l_down )
	{
		return l_return;
	}
	
	
	if( this.isLeaf )
	{					
		return this.children;
	}
	else
	{
		l_return = l_return.concat( this.front.getChildrenIn( p_x, p_y, p_width, p_height ) );
		l_return = l_return.concat( this.back.getChildrenIn( p_x, p_y, p_width, p_height ) );
		
		return l_return;
	}

};


BSPTree.prototype.depthWalk 					= function()
{
	var l_walk = this.rdepthWalk( this );
	return l_walk;
};


BSPTree.prototype.rdepthWalk 					= function( p_node )
{
	var l_walk = new Array();
	var l_current = p_node;
	
	if ( l_current == null || l_current.isLeaf )
	{
		return l_walk;
	}
	
	l_walk.push( l_current.back );
	l_walk = l_walk.concat( this.rdepthWalk( l_current.back ) );
	l_walk.push( l_current.front );
	l_walk = l_walk.concat( this.rdepthWalk( l_current.front ) );
	
	return l_walk;
};		


// filter
BSPTree.prototype.filter						= function( p_children, p_x, p_y, p_width, p_height )
{
	var visibles = new Array();
	var i = 0;
	var j = 0;
	var max = p_children.length; 
	
	for( i = 0; i < max; i++ )
	{
		obj = p_children[i];
		
		if( obj.x + obj.width < p_x )
			continue;
			
		if( obj.y + obj.height < p_y )
			continue;
			
		if( obj.x > p_x + p_width )
			continue;
			
		if( obj.y > p_y + p_height )
			continue;
		
		visibles[j] = obj;
		j++;
	}
	
	return visibles;
}



// debug
BSPTree.prototype.dumpXML 						= function( p_nodeName )
{
	
	var l_tabs = "";
	var l_nodeName = ( typeof(p_nodeName) == "undefined" ) ? "racine" : p_nodeName;
	var l_xml = "<"+l_nodeName+" numChildren=\""+this.children.length+"\"";
	var l_child;
	var i = 0;
	var l_max = 0;
	
	l_xml += " isLeaf=\""+this.isLeaf+"\"";
	l_xml += " n=\""+this.n+"\"";
	l_xml += " x=\""+this.x+"\"";
	l_xml += " y=\""+this.y+"\"";
	l_xml += " width=\""+this.width+"\"";
	l_xml += " height=\""+this.height+"\"";
	
	if( this.axis == BSPTree.Y_AXIS )
	{
		l_xml += " yLimit=\""+ (this.y + ( this.height / 2 ) )+"\"";
	}
	else
	{
		l_xml += " xLimit=\""+ ( this.x + ( this.width / 2 ) )+"\"";
	}
	l_xml += " axis=\""+this.axis+"\">";
	
	if( this.back != null )
	{
		l_xml += this.back.dumpXML("back");
	}
	
	if( this.front != null )
	{
		l_xml += this.front.dumpXML("front");
	}
	
	if( this.children.length > 0 )
	{
		l_max = this.children.length;
		
		l_xml += "<children>";
		
		for( i = 0; i < l_max; i++ )
		{
			l_child = this.children[i];
			
			l_xml += "<child x=\""+l_child.x+"\" y=\""+l_child.y+"\" width=\""+l_child.width+"\" height=\""+l_child.height+"\" offsetX=\""+l_child.offsetX+"\" offsetY=\""+l_child.offsetY+"\"></child>";
		}
		
		l_xml += "</children>";
	}
	l_xml += "</"+l_nodeName+">";
	
	return l_xml;
	
	
	
};


//clean
BSPTree.prototype.clean 						= function()
{
	if( !this.isLeaf )
	{
		this.back.clean();
		this.front.clean();
	}
	
	this.children = new Array();
};


//destroy
BSPTree.prototype.destroy 						= function()
{
	if( !this.isLeaf )
	{
		this.back.destroy();
		this.front.destroy();
	}
	
	var l_prop = "";
	
	for( l_prop in this )
	{
		this[l_prop] = null;
	}
	
};




//**************************C:\wamp\www\nd/Native2DDisplay/monster/org/display/boost/SimpleCulling.js**************************

/**

 * ...

 * @author Thot

 */



function SimpleCulling(){}

SimpleCulling.prototype.chidren = null;

SimpleCulling.prototype.addChild 	= function( p_child )
{
	this.children.push( p_child );
};


SimpleCulling.prototype.removeChild = function( p_child )
{
	var index = this.children.indexOf(p_child);
	if( index == -1 )
		return;
		
	this.children.splice( index, 1 );
};

SimpleCulling.prototype.init 	= function()
{
	this.children = new Array();
};

SimpleCulling.prototype.getVisibleChildrenIn = function ( p_x, p_y, p_width, p_height )
{
	var visibles = new Array();
	var tab = this.children;
	var i = 0;
	var j = 0;
	var max = tab.length; 
	
	for( i = 0; i < max; i++ )
	{
		obj = tab[i];
		
		if( obj.x + obj.width < p_x )
			continue;
			
		if( obj.y + obj.height < p_y )
			continue;
			
		if( obj.x > p_x + p_width )
			continue;
			
		if( obj.y > p_y + p_height )
			continue;
		
		visibles[j] = obj;
		j++;
	}
	
	return visibles;
}




//clean
SimpleCulling.prototype.clean = function()
{
	this.children = new Array();
};


//destroy
SimpleCulling.prototype.destroy = function()
{
	this.children = null;
};




//**************************C:\wamp\www\nd/Native2DDisplay/monster/org/display/camera/Camera.js**************************

/**
 * ...
 * @author HTML5
 */

function Camera() 
{
	this.transformGroup = new CameraGroup();
	this._transformData = [0,0,0,0,0,0];
	this.transformGroup.name = "cameraGroup";
}

Camera.prototype.pivotX 		= 0; 
Camera.prototype.pivotY 		= 0; 
Camera.prototype.pivotZ 		= 0; 
Camera.prototype.x 				= 0; 
Camera.prototype.y 				= 0; 
Camera.prototype.z 				= 0; 
Camera.prototype.width 			= 0; 
Camera.prototype.height 		= 0; 
Camera.prototype.zoom 			= 1; 
Camera.prototype.rotationX 		= 0; 
Camera.prototype.rotationY 		= 0; 
Camera.prototype.rotationZ 		= 0; 
Camera.prototype.name			= "camera";

Camera.prototype.bounds			= {"x":0,"y":0,"width":0,"height":0};
Camera.prototype.hasChanged 	= true;
Camera.prototype.transformGroup = null;
Camera.prototype._transformData  = null;

Camera.prototype.update = function()
{
	var hasChanged = false;
	var transformedData = this.transformData;
	var data = null;
	
	this.x 		>>= 0;
	this.y 		>>= 0;
	this.z 		>>= 0;
	this.width 	>>= 0;
	this.height >>= 0;
	this.pivotX >>= 0;
	this.pivotY >>= 0;
	this.pivotZ >>= 0;
	this.rotationX = ( this.rotationX % 360 ) >> 0;
	this.rotationY = ( this.rotationY % 360 ) >> 0;
	this.rotationZ = ( this.rotationZ % 360 ) >> 0;
	
	this.transformGroup.x = this.x;
	this.transformGroup.y = this.y;
	this.transformGroup.z = this.z;
	this.transformGroup.pivotX = this.pivotX;
	this.transformGroup.pivotY = this.pivotY;
	this.transformGroup.pivotZ = this.pivotZ;
	this.transformGroup.rotationX = this.rotationX;
	this.transformGroup.rotationY = this.rotationY;
	this.transformGroup.rotationZ = this.rotationZ;
	
	this.transformGroup.scaleX = this.zoom;
	this.transformGroup.scaleY = this.zoom;
	this.transformGroup.scaleZ = 1;
						
	
	this.transformGroup.update( new Date().getTime() );
	data = this.transformGroup.transformData;
	
	this.hasChanged = ( 
							this._transformData[0] 	 	!= data[0] 	|| 
							this._transformData[1] 	 	!= data[1] 	|| 
							this._transformData[2] 	 	!= data[2] 	|| 
							this._transformData[3] 	 	!= data[3] 	|| 
							this._transformData[4] 	 	!= data[4] 	|| 
							this._transformData[5] 	 	!= data[5] 
					);
					
	this._transformData = data;
	
	if( this.hasChanged )
	{
		var cam_w = this.width / this.zoom;
		var cam_h = this.height / this.zoom;
		
		var cam_x = this.x + this.pivotX - ( this.pivotX / this.zoom );
		var cam_y = this.y + this.pivotY - ( this.pivotY / this.zoom );
		
		this.bounds = {"x":cam_x,"y":cam_y,"width":cam_w,"height":cam_h};
	}
	
	return this.hasChanged;
};



//**************************C:\wamp\www\nd/Native2DDisplay/monster/org/display/primitive/Sprite.js**************************


/**
 * ...
 * @author HTML5
 */

function Sprite()
{
}

Sprite.prototype.uv					= [0, 0, 1, 1];
Sprite.prototype.x 					= 0;
Sprite.prototype.y 					= 0;
Sprite.prototype.z 					= 0;
Sprite.prototype.width 				= 0;
Sprite.prototype.height 			= 0;
Sprite.prototype.alpha 				= 1;
Sprite.prototype.textureId 			= 0;
Sprite.prototype.name 				= "";
Sprite.prototype.displayList 		= null;
Sprite.prototype.transformGroup		= null;
Sprite.prototype.mask				= null;
Sprite.prototype._transformData		= [1,0,0,1,0,0];

Sprite._canvas						= document.createElement("canvas");



Sprite.prototype.drawMask = function( p_texture, p_context )
{
	var canvas = Sprite._canvas;
	var ctx =  canvas.getContext("2d");
	
	var sx = this.uv[0] * p_texture.data.width;
	var sy = this.uv[1] * p_texture.data.height;
	var sw = this.uv[2] * p_texture.data.width;
	var sh = this.uv[3] * p_texture.data.height;
	
	sw -= sx;
	sh -= sy;
	
	
	canvas.width = this.width;
	canvas.height = this.height;
	
	ctx.drawImage( 		this.mask, 
						0, 
						0,
						this.width, 
						this.height	);
						
	
	
	ctx.globalCompositeOperation = "source-in";
	
	if( p_texture.type == Texture2D.COLOR_TEXTURE )
	{
		ctx.fillStyle = p_texture.color;
		ctx.fillRect( this.x , this.y , this.width, this.height );
	}
	else
	{
		ctx.drawImage( 	p_texture.data, 
						sx, 
						sy, 
						sw, 
						sh, 
						0, 
						0, 
						this.width, 
						this.height	);
	}
	
	
	p_context.drawImage( canvas, this.x, this.y, this.width, this.height );
							
};

Sprite.prototype.render = function( p_context )
{

	
	var isAlpha 	= ( this.alpha != 1 );
	var texture		= TextureManager.getInstance().getTextureById(this.textureId);
	var maskCtx		= null;
	
	if( texture == undefined || texture == null )
	{
		return;
	}
	
	var sx = this.uv[0] * texture.data.width;
	var sy = this.uv[1] * texture.data.height;
	var sw = this.uv[2] * texture.data.width;
	var sh = this.uv[3] * texture.data.height;
	
	sw -= sx;
	sh -= sy;
	
	p_context.save();
		
	if( isAlpha )
	{
		p_context.globalAlpha = this.alpha;
	}
	
	
	if( this.transformGroup != null )
	{
		this._transformData = this.transformGroup.transformData;
	}
	
	p_context.setTransform( 
					this._transformData[0],
					this._transformData[1],
					this._transformData[2],
					this._transformData[3],
					this._transformData[4],
					this._transformData[5] );
	
					
					
	if( this.mask != null )
	{
		this.drawMask( texture, p_context );
	}
	else
	{		
		if( texture.type == Texture2D.COLOR_TEXTURE )
		{
			p_context.fillStyle = texture.color;
			p_context.fillRect( this.x , this.y , this.width, this.height );
		}
		else
		{
			p_context.drawImage( 	texture.data, 
									sx, 
									sy, 
									sw, 
									sh, 
									this.x, 
									this.y, 
									this.width, 
									this.height	);
		}
	}
						
	p_context.restore();
};



//**************************C:\wamp\www\nd/Native2DDisplay/monster/org/display/render/DisplayList.js**************************

/**
 * ...
 * @author HTML5
 */
 
function DisplayList() 
{
	this.children 	= new Array();
	this.updateList = new Array();
	this.boost		= null;
}


DisplayList.prototype.children 		= null;
DisplayList.prototype.updateList 	= null;
DisplayList.prototype.boost 		= null;


DisplayList.prototype.updateDynamics = function()
{
	if( this.boost == null )
		return;
		
	var child = null;
		
	while( this.updateList.length > 0 )
	{
		child = this.updateList[0];
		this.boost.removeChild( child );
		this.boost.addChild( child );
		this.updateList.shift();
	}
};

DisplayList.prototype.getVisibleChildrenIn = function( p_x, p_y, p_width, p_height )
{
	this.updateDynamics();
	var tab = ( this.boost == null ) ? this.children : this.boost.getVisibleChildrenIn( p_x, p_y, p_width, p_height );
	return tab;	
};

DisplayList.prototype.addChild = function( p_child )
{
	p_child.displayList = this;
	this.children.push( p_child );
	
	if( this.boost != null )
	{
		this.boost.addChild( p_child );
	}
};

DisplayList.prototype.removeChild = function( p_child )
{
	var index = this.children.indexOf( p_child );
	if (index > -1)
	{
		this.children.splice( index, 1 );
	}
	
	if( this.boost != null )
	{
		this.boost.removeChild( p_child );
	}
};

DisplayList.prototype.removeChildren = function()
{	
	if( this.boost != null )
	{
		this.boost.clean();
	}
	
	this.children = new Array();
};

DisplayList.prototype.destroy = function()
{
	this.children = null;
	if( this.boost != null )
	{
		this.boost.destroy();
		this.boost = null;
	}
};




//**************************C:\wamp\www\nd/Native2DDisplay/monster/org/display/render/Layer.js**************************

/**
 * ...
 * @author HTML5
 */

function Layer() 
{
	this.displayList 	= new DisplayList();
	this.canvas  		= null;
	this.context 		= null;
}

Layer.prototype.displayList 	= null;
Layer.prototype.lazy 			= false;
Layer.prototype.canvas 			= null;
Layer.prototype.context 		= null;
Layer.prototype.sorted 			= false;
Layer.prototype.sortFunc		= null;
Layer.prototype.sortArgs		= null;
Layer.prototype.name 			= "";



//**************************C:\wamp\www\nd/Native2DDisplay/monster/org/display/render/Renderer2D.js**************************

/**
 * ...
 * @author HTML5
 */

function Renderer2D() 
{
	this.camera = new Camera();
	this.layers = new Array();
}

Renderer2D.prototype.numDraws = 0;
Renderer2D.prototype.camera = null;
Renderer2D.prototype.layers = null;

Renderer2D.prototype.render = function()
{
	
	var i = 0;
	var j = 0;
	var max = this.layers.length;
	var max2 = 0;
	var layer = null;
	var update = this.camera.update();
	var children = null;
	var field = this.camera.visibleRect;
	var canvas = null;
	var context = null;
	var sprite = null;
	var camera = this.camera;
	var inc = 0;
	var transformData = this.camera.transformData;
	
	
	var camBounds = camera.bounds;
	
		
		
	for( i = 0; i < max; i++ )
	{
		
		layer = this.layers[i];
		
	
		if( ( layer.lazy && !update ) || layer.canvas == null || layer.context == null )
		{
			continue;
		}
		
		
		children = layer.displayList.getVisibleChildrenIn( camBounds.x , camBounds.y, camBounds.width, camBounds.height );
		
		if( !layer.sorted && layer.sortFunc != null )
		{
			children = layer.sortFunc.apply( this, [children].concat( layer.sortArgs ) );
		}
		
		canvas = layer.canvas;
		context = layer.context;
		
		
		context.clearRect( 0, 0, canvas.width, canvas.height );
		context.save();
	
		max2 = children.length;
		
		for( j = 0; j < max2; j++ )
		{
			sprite = children[j];
			sprite.render( context );
		}
		
		inc += max2;
		
		
		context.restore();
	}
	
	this.numDraws = inc;
	
	
	
}



//**************************C:\wamp\www\nd/Native2DDisplay/monster/org/display/texture/Texture2D.js**************************

/**
 * ...
 * @author HTML5
 */

function Texture2D() {}


Texture2D.COLOR_TEXTURE 	= 0;
Texture2D.BMP_TEXTURE 		= 1;

Texture2D.prototype.type 	= Texture2D.COLOR_TEXTURE;
Texture2D.prototype.url 	= null;
Texture2D.prototype.id		= -1;
Texture2D.prototype.data	= null;
Texture2D.prototype.color	= "#000000";
Texture2D.prototype.destroy	= function()
{
	this.type = null;
	this.url = null;
	this.id = null;
	this.data = null;
	this.color = null;
	this.destroy = null;
};





//**************************C:\wamp\www\nd/Native2DDisplay/monster/org/display/texture/TextureManager.js**************************

/**
 * ...
 * @author Thot
 */

function TextureManager()
{
	this._textures = new Array();
}

//static
TextureManager._instance = null;
TextureManager.getInstance = function()
{
	if( TextureManager._instance == null )
	{
		TextureManager._instance = new TextureManager();
	}
	
	return TextureManager._instance;
};

// public

TextureManager.prototype._textures = null;

TextureManager.prototype.addTexture = function( p_texture )
{
	this._textures[p_texture.id] = p_texture;
};

TextureManager.prototype.getTextureById = function( p_id )
{
	return this._textures[p_id];
};

TextureManager.prototype.destroy = function()
{
	TextureManager._instance = null;
	this._textures = null;
	delete this._textures;	
};



//**************************C:\wamp\www\nd/Native2DDisplay/monster/org/display/transform/CameraGroup.js**************************

/**
 * ...
 * @author Thot
 */

function CameraGroup()
{
	this.matrix = new Matrix4x4();
	this.transformData = [1,0,0,1,0,0];
	this.subGroups = new Array();
}

CameraGroup.prototype.matrix 		= null;
CameraGroup.prototype.name 			= null;
CameraGroup.prototype.rotationX 	= 0;
CameraGroup.prototype.rotationY 	= 0;
CameraGroup.prototype.rotationZ 	= 0;
CameraGroup.prototype.scaleX		= 1;
CameraGroup.prototype.scaleY		= 1;
CameraGroup.prototype.scaleZ		= 1;
CameraGroup.prototype.pivotX		= 0;
CameraGroup.prototype.pivotY		= 0;
CameraGroup.prototype.pivotZ		= 0;
CameraGroup.prototype.x				= 0;
CameraGroup.prototype.y				= 0;
CameraGroup.prototype.z				= 0;
CameraGroup.prototype.parentGroup 	= null;
CameraGroup.prototype.transformData = null;	
CameraGroup.prototype.subGroups		= null;

CameraGroup.prototype.update = function()
{	
	
	this.x 		>>= 0;
	this.y 		>>= 0;
	this.z 		>>= 0;
	this.width 	>>= 0;
	this.height >>= 0;
	this.pivotX >>= 0;
	this.pivotY >>= 0;
	this.pivotZ >>= 0;
	this.rotationX = ( this.rotationX % 360 ) >> 0;
	this.rotationY = ( this.rotationY % 360 ) >> 0;
	this.rotationZ = ( this.rotationZ % 360 ) >> 0;
	this.matrix.identity();
	
	var i = 0;
	var max = this.subGroups.length;
	var group = null;
	
	if( this.parentGroup != null )
	{
		this.matrix.multiply(this.parentGroup.matrix);
	}
	

	this.matrix
		.translate( this.pivotX, this.pivotY, this.pivotZ )
		.scale( this.scaleX, this.scaleY, this.scaleZ )
		.rotateZ( this.rotationZ )
		.rotateX( this.rotationY )
		.rotateY( this.rotationX )
		.translate( -this.pivotX, -this.pivotY, -this.pivotZ )
		.translate(  -this.x, -this.y, -this.z);
	
	this.transformData = this.matrix.to2D();
	
	if( max > 0 )
	{
		for( i = 0; i < max; i++ )
		{
			group = this.subGroups[i];
			group.update();
		}
	}
	
};

CameraGroup.prototype.addSubGroup = function( p_group )
{
	p_group.parentGroup = this;
	this.subGroups.push( p_group );
};

CameraGroup.prototype.removeSubGroup = function( p_group )
{
	var index = this.subGroups.indexOf( p_group );
	if( index == -1 )
		return;
		
	this.subGroups[index].parentGroup = null;
	this.subGroups.splice( index, 1 );
};



//**************************C:\wamp\www\nd/Native2DDisplay/monster/org/display/transform/TransformGroup.js**************************

/**
 * ...
 * @author Thot
 */

function TransformGroup()
{
	this.matrix = new Matrix4x4();
	this.transformData = [1,0,0,1,0,0];
	this.subGroups = new Array();
}

TransformGroup.prototype.matrix 		= null;
TransformGroup.prototype.name 			= null;
TransformGroup.prototype.rotationX 		= 0;
TransformGroup.prototype.rotationY 		= 0;
TransformGroup.prototype.rotationZ 		= 0;
TransformGroup.prototype.scaleX			= 1;
TransformGroup.prototype.scaleY			= 1;
TransformGroup.prototype.scaleZ			= 1;
TransformGroup.prototype.pivotX			= 0;
TransformGroup.prototype.pivotY			= 0;
TransformGroup.prototype.pivotZ			= 0;
TransformGroup.prototype.x				= 0;
TransformGroup.prototype.y				= 0;
TransformGroup.prototype.z				= 0;
TransformGroup.prototype.parentGroup 	= null;
TransformGroup.prototype.transformData 	= null;	
TransformGroup.prototype.subGroups		= null;

TransformGroup.prototype.update = function()
{	
	
	this.x 		>>= 0;
	this.y 		>>= 0;
	this.z 		>>= 0;
	this.width 	>>= 0;
	this.height >>= 0;
	this.pivotX >>= 0;
	this.pivotY >>= 0;
	this.pivotZ >>= 0;
	this.rotationX = ( this.rotationX % 360 ) >> 0;
	this.rotationY = ( this.rotationY % 360 ) >> 0;
	this.rotationZ = ( this.rotationZ % 360 ) >> 0;
	this.matrix.identity();
	
	var i = 0;
	var max = this.subGroups.length;
	var group = null;
	
	if( this.parentGroup != null )
	{
		this.matrix.multiply(this.parentGroup.matrix);
	}
	

	this.matrix
		.translate( this.x + this.pivotX, this.y + this.pivotY, this.z + this.pivotZ )
		.scale( this.scaleX, this.scaleY, this.scaleZ )
		.rotateX( this.rotationX )
		.rotateY( this.rotationY )
		.rotateZ( this.rotationZ )
		.translate( -this.pivotX, -this.pivotY, -this.pivotZ );
	
	this.transformData = this.matrix.to2D();
	
	if( max > 0 )
	{
		for( i = 0; i < max; i++ )
		{
			group = this.subGroups[i];
			group.update();
		}
	}
	
};

TransformGroup.prototype.addSubGroup = function( p_group )
{
	p_group.parentGroup = this;
	this.subGroups.push( p_group );
};

TransformGroup.prototype.removeSubGroup = function( p_group )
{
	var index = this.subGroups.indexOf( p_group );
	if( index == -1 )
		return;
		
	this.subGroups[index].parentGroup = null;
	this.subGroups.splice( index, 1 );
};



//**************************C:\wamp\www\nd/Native2DDisplay/monster/org/geom/Matrix4x4.js**************************

/**
 * ...
 * @author Thot
 */

function Matrix4x4()
{
	this.init (1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);
}

// public
Matrix4x4.prototype.data = null;



Matrix4x4.prototype.init = function( 		a, b, c, d, 
											e, f, g, h, 
											i, j, k, l, 
											m, n, o, p ){
											
										
		
	var container = null;
	container = new Array();

	container[0] 	= a;
	container[1] 	= b;
	container[2] 	= c;
	container[3] 	= d;
	container[4] 	= e;
	container[5] 	= f;
	container[6] 	= g;
	container[7] 	= h;
	container[8] 	= i;
	container[9] 	= j;
	container[10] 	= k;
	container[11] 	= l;
	container[12] 	= m;
	container[13] 	= n;
	container[14] 	= o;
	container[15] 	= p;
	
	this.data = container;
	return this;
	
};

Matrix4x4.prototype.clone = function()
{
	var matrix = new Matrix4x4();
	var i = 16;
	
	while( --i > -1 )
	{
		matrix.data[i] = this.data[i];
	}
	
	return matrix;
};

Matrix4x4.prototype.translate = function( tx, ty, tz )
{
	Matrix4x4._TRANSLATE_MATRIX.data[3] = tx;
	Matrix4x4._TRANSLATE_MATRIX.data[7] = ty;
	Matrix4x4._TRANSLATE_MATRIX.data[11] = tz;
				
	this.multiply( Matrix4x4._TRANSLATE_MATRIX );
	return this;
};

Matrix4x4.prototype.scale = function( sx, sy, sz )
{	
	
	Matrix4x4._SCALE_MATRIX.data[0] = sx;
	Matrix4x4._SCALE_MATRIX.data[5] = sy;
	Matrix4x4._SCALE_MATRIX.data[10] = sz;
				
	this.multiply( Matrix4x4._SCALE_MATRIX );
	return this;
};


Matrix4x4.prototype.rotateX = function( p_rotation )
{
	var c = Matrix4x4._cos[p_rotation];
	var s = Matrix4x4._sin[p_rotation];
	
	Matrix4x4._ROTATION_X_MATRIX.data[5] = c;
	Matrix4x4._ROTATION_X_MATRIX.data[6] = -s;
	Matrix4x4._ROTATION_X_MATRIX.data[9] = s;
	Matrix4x4._ROTATION_X_MATRIX.data[10] = c;
				
	this.multiply( Matrix4x4._ROTATION_X_MATRIX );
	return this;
};

Matrix4x4.prototype.rotateY = function( p_rotation )
{
	var c = Matrix4x4._cos[p_rotation];
	var s = Matrix4x4._sin[p_rotation];
	
	Matrix4x4._ROTATION_Y_MATRIX.data[00] = c;
	Matrix4x4._ROTATION_Y_MATRIX.data[2] = -s;
	Matrix4x4._ROTATION_Y_MATRIX.data[8] = s;
	Matrix4x4._ROTATION_Y_MATRIX.data[10] = c;
				
	this.multiply( Matrix4x4._ROTATION_Y_MATRIX );
	
	return this;
};

Matrix4x4.prototype.rotateZ = function( p_rotation )
{
	var c = Matrix4x4._cos[p_rotation];
	var s = Matrix4x4._sin[p_rotation];
						
	Matrix4x4._ROTATION_Z_MATRIX.data[0] = c;
	Matrix4x4._ROTATION_Z_MATRIX.data[1] = -s;
	Matrix4x4._ROTATION_Z_MATRIX.data[4] = s;
	Matrix4x4._ROTATION_Z_MATRIX.data[5] = c;
				
	this.multiply( Matrix4x4._ROTATION_Z_MATRIX );
	
	return this;
};

Matrix4x4.prototype.multiplyByNumber = function( p_number )
{
	var data1 = this.data;
	
	data1[0] *= p_number;
	data1[1] *= p_number;
	data1[2] *= p_number;
	data1[3] *= p_number;
	data1[4] *= p_number;
	data1[5] *= p_number;
	data1[6] *= p_number;
	data1[7] *= p_number;
	data1[8] *= p_number;
	data1[9] *= p_number;
	data1[10] *= p_number;
	data1[11] *= p_number;
	data1[12] *= p_number;
	data1[13] *= p_number;
	data1[14] *= p_number;
	data1[15] *= p_number;
	
	return this;
};

Matrix4x4.prototype.multiply = function( p_mat )
{
	var data1 = this.data;
	var data2 = p_mat.data;
	
	var a00 = data1[0], a01 = data1[1], a02 = data1[2], a03 = data1[3];
	var a10 = data1[4], a11 = data1[5], a12 = data1[6], a13 = data1[7];
	var a20 = data1[8], a21 = data1[9], a22 = data1[10], a23 = data1[11];
	var a30 = data1[12], a31 = data1[13], a32 = data1[14], a33 = data1[15];
	
	var b00 = data2[0], b01 = data2[1], b02 = data2[2], b03 = data2[3];
	var b10 = data2[4], b11 = data2[5], b12 = data2[6], b13 = data2[7];
	var b20 = data2[8], b21 = data2[9], b22 = data2[10], b23 = data2[11];
	var b30 = data2[12], b31 = data2[13], b32 = data2[14], b33 = data2[15];
	
	data1[0] 	= a00 * b00 + a01 * b10 + a02 * b20 + a03 * b30;
	data1[1] 	= a00 * b01 + a01 * b11 + a02 * b21 + a03 * b31;
	data1[2] 	= a00 * b02 + a01 * b12 + a02 * b22 + a03 * b32;
	data1[3] 	= a00 * b03 + a01 * b13 + a02 * b23 + a03 * b33;
	
	data1[4] 	= a10 * b00 + a11 * b10 + a12 * b20 + a13 * b30;
	data1[5] 	= a10 * b01 + a11 * b11 + a12 * b21 + a13 * b31;
	data1[6] 	= a10 * b02 + a11 * b12 + a12 * b22 + a13 * b32;
	data1[7] 	= a10 * b03 + a11 * b13 + a12 * b23 + a13 * b33;
	
	data1[8] 	= a20 * b00 + a21 * b10 + a22 * b20 + a23 * b30;
	data1[9] 	= a20 * b01 + a21 * b11 + a22 * b21 + a23 * b31;
	data1[10] 	= a20 * b02 + a21 * b12 + a22 * b22 + a23 * b32;
	data1[11] 	= a20 * b03 + a21 * b13 + a22 * b23 + a23 * b33;
	
	data1[12] 	= a30 * b00 + a31 * b10 + a32 * b20 + a33 * b30;
	data1[13] 	= a30 * b01 + a31 * b11 + a32 * b21 + a33 * b31;
	data1[14] 	= a30 * b02 + a31 * b12 + a32 * b22 + a33 * b32;
	data1[15] 	= a30 * b03 + a31 * b13 + a32 * b23 + a33 * b33;
	
	return this;
};


Matrix4x4.prototype.determinant = function() 
{
		var data = this.data;
        // Cache the matrix values (makes for huge speed increases!)
        var a00 = data[0], a01 = data[1], a02 = data[2], a03 = data[3];
        var a10 = data[4], a11 = data[5], a12 = data[6], a13 = data[7];
        var a20 = data[8], a21 = data[9], a22 = data[10], a23 = data[11];
        var a30 = data[12], a31 = data[13], a32 = data[14], a33 = data[15];

        return  ( 		a30*a21*a12*a03 - a20*a31*a12*a03 - a30*a11*a22*a03 + a10*a31*a22*a03 +
                        a20*a11*a32*a03 - a10*a21*a32*a03 - a30*a21*a02*a13 + a20*a31*a02*a13 +
                        a30*a01*a22*a13 - a00*a31*a22*a13 - a20*a01*a32*a13 + a00*a21*a32*a13 +
                        a30*a11*a02*a23 - a10*a31*a02*a23 - a30*a01*a12*a23 + a00*a31*a12*a23 +
                        a10*a01*a32*a23 - a00*a11*a32*a23 - a20*a11*a02*a33 + a10*a21*a02*a33 +
                        a20*a01*a12*a33 - a00*a21*a12*a33 - a10*a01*a22*a33 + a00*a11*a22*a33 	);
};

Matrix4x4.prototype.identity = function()
{
	this.init( 1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1 );
	return this;
};

Matrix4x4.prototype.inverse = function() 
{
	var data = this.data;
	// Cache the matrix values (makes for huge speed increases!)
	var a00 = data[0], a01 = data[1], a02 = data[2], a03 = data[3];
	var a10 = data[4], a11 = data[5], a12 = data[6], a13 = data[7];
	var a20 = data[8], a21 = data[9], a22 = data[10], a23 = data[11];
	var a30 = data[12], a31 = data[13], a32 = data[14], a33 = data[15];
	
	var b00 = a00*a11 - a01*a10;
	var b01 = a00*a12 - a02*a10;
	var b02 = a00*a13 - a03*a10;
	var b03 = a01*a12 - a02*a11;
	var b04 = a01*a13 - a03*a11;
	var b05 = a02*a13 - a03*a12;
	var b06 = a20*a31 - a21*a30;
	var b07 = a20*a32 - a22*a30;
	var b08 = a20*a33 - a23*a30;
	var b09 = a21*a32 - a22*a31;
	var b10 = a21*a33 - a23*a31;
	var b11 = a22*a33 - a23*a32;
	
	// Calculate the determinant (inlined to avoid double-caching)
	var d = b00*b11 - b01*b10 + b02*b09 + b03*b08 - b04*b07 + b05*b06;
	var id = 1/d;
	
	data[0] = (a11*b11 - a12*b10 + a13*b09)*id;
	data[1] = (-a01*b11 + a02*b10 - a03*b09)*id;
	data[2] = (a31*b05 - a32*b04 + a33*b03)*id;
	data[3] = (-a21*b05 + a22*b04 - a23*b03)*id;
	data[4] = (-a10*b11 + a12*b08 - a13*b07)*id;
	data[5] = (a00*b11 - a02*b08 + a03*b07)*id;
	data[6] = (-a30*b05 + a32*b02 - a33*b01)*id;
	data[7] = (a20*b05 - a22*b02 + a23*b01)*id;
	data[8] = (a10*b10 - a11*b08 + a13*b06)*id;
	data[9] = (-a00*b10 + a01*b08 - a03*b06)*id;
	data[10] = (a30*b04 - a31*b02 + a33*b00)*id;
	data[11] = (-a20*b04 + a21*b02 - a23*b00)*id;
	data[12] = (-a10*b09 + a11*b07 - a12*b06)*id;
	data[13] = (a00*b09 - a01*b07 + a02*b06)*id;
	data[14] = (-a30*b03 + a31*b01 - a32*b00)*id;
	data[15] = (a20*b03 - a21*b01 + a22*b00)*id;
	
	return this;
};

Matrix4x4.prototype.transpose = function() 
{		
	// Cache the matrix values (makes for huge speed increases!)
	var data = this.data;
	
	var a00 = data[0], a01 = data[1], a02 = data[2], a03 = data[3];
	var a10 = data[4], a11 = data[5], a12 = data[6], a13 = data[7];
	var a20 = data[8], a21 = data[9], a22 = data[10], a23 = data[11];
	var a30 = data[12], a31 = data[13], a32 = data[14], a33 = data[15];

	data[0] = a00;
	data[1] = a10;
	data[2] = a20;
	data[3] = a30;
	data[4] = a01;
	data[5] = a11;
	data[6] = a21;
	data[7] = a31;
	data[8] = a02;
	data[9] = a12;
	data[10] = a22;
	data[11] = a32;
	data[12] = a03;
	data[13] = a13;
	data[14] = a23;
	data[15] = a33;
	
	return this;
};


Matrix4x4.prototype.frustum = function(left, right, bottom, top, near, far, dest) 
{
	var data = this.data;
	var temp1 = 2 * near;
	var temp2 = right - left;
	var temp3 = top - bottom;
	var temp4 = far - near;
	
	data[0] = temp1 / temp2;
	data[1] = 0;
	data[2] = 0;
	data[3] = 0;
	data[4] = 0;
	data[5] = temp1 / temp3;
	data[6] = 0;
	data[7] = 0;
	data[8] = (right + left) / temp2;
	data[9] = (top + bottom) / temp3;
	data[10] = (-far - near) / temp4;
	data[11] = -1;
	data[12] = 0;
	data[13] = 0;
	data[14] = (-temp1 * far) / temp4;
	data[15] = 0;
	return this;
};

Matrix4x4.prototype.perspective = function(fovy, aspect, near, far) 
{
	var top = near * Math.tan(fovy * Math.PI / 360);
	var right = top * aspect;
	this.frustum(-right, right, -top, top, near, far);
	return this;
};

Matrix4x4.prototype.ortho = function(left, right, bottom, top, near, far ) 
{
	var lr = (left - right);
	var tb = (top - bottom);
	var fn = (far - near);
	var data = this.data;
	data[0] = 2 / lr;
	data[1] = 0;
	data[2] = 0;
	data[3] = 0;
	data[4] = 0;
	data[5] = 2 / tb;
	data[6] = 0;
	data[7] = 0;
	data[8] = 0;
	data[9] = 0;
	data[10] = -2 / fn;
	data[11] = 0;
	data[12] = (left + right) / lr;
	data[13] = (top + bottom) / tb;
	data[14] = (far + near) / fn;
	data[15] = 1;
	
	return this;
};

Matrix4x4.prototype.str = function() 
{
	var data = this.data;
	return '[\n' + data[0] + ', ' + data[1] + ', ' + data[2] + ', ' + data[3] + 
			'\n, '+ data[4] + ', ' + data[5] + ', ' + data[6] + ', ' + data[7] + 
			'\n, '+ data[8] + ', ' + data[9] + ', ' + data[10] + ', ' + data[11] + 
			'\n, '+ data[12] + ', ' + data[13] + ', ' + data[14] + ', ' + data[15] + ']';
};


Matrix4x4.prototype.to2D = function()
{
	var data = new Array();
	data[0] = this.data[0];
	data[1] = this.data[4];
	data[2] = this.data[1];
	data[3] = this.data[5];
	data[4] = this.data[3];
	data[5] = this.data[7];
	
	return data;
};


// static

Matrix4x4._getMatrixPattern = function( p_type )
{
	var c = Matrix4x4._cos[0];
	var s = Matrix4x4._sin[0];
	var sx = 1;
	var sy = 1;
	var sz = 1;
	var tx = 0;
	var ty = 0;
	var tz = 0;
	var mat = new Matrix4x4();
	
	switch( p_type )
	{
		case "translate":
			mat.init (	
							1, 	0, 	0, 	tx,
							0, 	1, 	0, 	ty,
							0, 	0, 	1, 	tz,
							0, 	0, 	0, 	1
					);
			break;
			
		case "scale":
			mat.init( 
							sx, 0, 	0, 	0,
							0, 	sy, 0, 	0,
							0, 	0, 	sz, 0,
							0, 	0, 	0, 	1
					);
			break;
			
		case "rotX":
			mat.init(
							1, 	0, 	0, 	0,
							0, 	c, -s, 	0,
							0, 	s, 	c, 	0,
							0, 	0, 	0, 	1
					);
			break;
			
		case "rotY":
			mat.init(
							c, 0, -s,0,
							0, 1, 0, 0,
							s, 0, c, 0,
							0, 0, 0, 1
						);
					
				break;
			
		case "rotZ":
			mat.init(
						c, 	-s, 0, 	0,
						s, 	c, 	0, 	0,
						0, 	0, 	1, 	0,
						0, 	0, 	0, 	1
					);
			break;
	}
	
	return mat;
};


Matrix4x4._cos = new Array();
Matrix4x4._sin = new Array();
Matrix4x4._tan = new Array();

Matrix4x4.TO_RADIANS = Math.PI / 180;
Matrix4x4.TO_DEGREES = 180 / Math.PI;


Matrix4x4.init = function()
{
	var i = 0;
	for( i = 0; i < 360; i++ )
	{
		Matrix4x4._cos[i] = Math.cos( i * Matrix4x4.TO_RADIANS );
		Matrix4x4._sin[i] = Math.sin( i * Matrix4x4.TO_RADIANS );
		Matrix4x4._tan[i] = Math.tan( i * Matrix4x4.TO_RADIANS );
	}
};

Matrix4x4.init();

Matrix4x4._ROTATION_X_MATRIX 	= Matrix4x4._getMatrixPattern("rotX");
Matrix4x4._ROTATION_Y_MATRIX 	= Matrix4x4._getMatrixPattern("rotY");
Matrix4x4._ROTATION_Z_MATRIX 	= Matrix4x4._getMatrixPattern("rotZ");
Matrix4x4._TRANSLATE_MATRIX 	= Matrix4x4._getMatrixPattern("translate");
Matrix4x4._SCALE_MATRIX			= Matrix4x4._getMatrixPattern("scale");
Matrix4x4._instance				= new Matrix4x4();



//**************************C:\wamp\www\nd/Native2DDisplay/monster/org/geom/Vector4D.js**************************

/**
 * ...
 * @author Thot
 */

function Vector4D()
{
	this.data = [0,0,0,1];
}

Vector4D.prototype.data = null;



//**************************C:\wamp\www\nd/Native2DDisplay/monster/org/math/FastMath.js**************************

/**
 * ...
 * @author Thot
 */

function FastMath(){}

FastMath._cos = new Array();
FastMath._sin = new Array();
FastMath._tan = new Array();

FastMath.TO_RADIANS = Math.PI / 180;
FastMath.TO_DEGREES = 180 / Math.PI;


FastMath.init = function()
{
	var i = 0;
	for( i = 0; i < 360; i++ )
	{
		FastMath._cos[i] = Math.cos( i * FastMath.TO_RADIANS );
		FastMath._sin[i] = Math.sin( i * FastMath.TO_RADIANS );
		FastMath._tan[i] = Math.tan( i * FastMath.TO_RADIANS );
	}
};


FastMath.init();


